<html>
 <head>
    <title>[var.TITLE]</title>
    <link href="[var.ROOT_CSS_DIR]/main.css" rel="STYLESHEET" type="text/css" charset="iso-8859-1" hreflang="en-us">
    <link href="[var.ROOT_CSS_DIR]/facet/style.css" rel="STYLESHEET" type="text/css" charset="iso-8859-1" hreflang="en-us">
    <script type="text/javascript" src="[var.ROOT_DIR]js/common.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/doiMenuDOM.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/functions.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmenu.php"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmenu.cfg"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsformgrid.php?session=[var.SessionVar]"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmasks.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsverify.php?session=[var.SessionVar]"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsinit.php?session=[var.SessionVar]"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jquery.min.js"></script>
 </head>
 <body bgcolor="FFFFFF" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
    <table border="0" cellspacing="0" cellpadding="0" width="100%" align="[var.POSITION]">
        <tr>
            <td>[tbs_include.onshow;file=[var.HTMLHeader];getob;]</td>
        </tr>
        <tr>
            <td>
            <table border="0" cellspacing="0" cellpadding="0" width="100%">
                <tr>
                    <td class="mainmenu2"><img src="images/spacer.gif" height="1" width="1"></td>
                </tr>
                <tr>
                    <td background="[var.ROOT_IMG_DIR]/back-menu.gif">
                    <table border="0" cellspacing="0" cellpadding="0" width="100%">
                        <tr>
                            <td>
                                <script language="JavaScript" type="text/JavaScript">menu.Build();</script>
                          </td>
                          <td class="head-login">Login as [var.USERPROFILE_NAME]</td>
                        </tr>
                      </table>
                    </td>
                </tr>

                <tr>
                    <td class="mainmenu2"><img src="images/spacer.gif" height="1" width="1"></td>
                </tr>
            </table>
            </td>
        </tr>
        <tr height="100%">
            <td>
            <table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
                <tr valign="top">
                    <td width="100%">
                        <table border="0" cellspacing="0" cellpadding="0" width="100%">
                            <tr>
                                <td class="head-path"></td>
                                <td class="corner-date">[var.CORNER_DATE]</td>
                            </tr>
                        </table>
                        <table border="0" cellspacing="0" cellpadding="5" width="100%">
                            <tr>
                                <td class="FacetHeaderContent" >.:[var.SubHeaderTitle]:.</td>
                            </tr>
                        </table>

                        <table border="0" cellspacing="0" cellpadding="5" width="100%">
                         <form method="post" action="[var.FormAction]" name="[var.HTMLFormName]" >
                            <tr>
                                <td class="contentTitleOperational">
                                Menu
                                </td>
                            </tr>
                            <tr>
                                <td class="contentOperational">
                                <table cellspacing="2" cellpadding="0">
                                 <tr>
                                   <td>
                                    <input type="button" name="Action" value="<<Back" class="button" onClick="self.location.replace('[sys.script_name]')">
                                   </td>
                                   <td>
									 <input name="FormAction" type="submit" value="Save" class="button" ONCLICK="return checkVerification();">
								   </td>
                                   <td>
                                     <input type="button" name="Action" value="Done" class="button" onClick="self.location.replace('[var.SERVER_URL]')">
                                   </td>
                                   <!--
                                   <td>
                                     <input type="button" name="Action" value="Print to PDF" class="button" onClick="return SubmitPDF();">
                                   </td>
                                   -->
                                 </tr>
                                </table>
                                </td>
                            </tr>
                            <tr>
                                <td class="contentOperational">


                         <!--TABLE MASTER-->
                         <table width="1400" border="0">
                             <tr>
                                 <td width="50%" valign="top">


                        <!-- FORM SECTION -->
                        <table border="0" cellspacing="0" cellpadding="0">

                       				
                       				<tr>
                                <td class="fieldCaption" align="right">LPJ Code</td>
                                <td class="fieldCaption">:</td>
                                <td class="fieldCaption">
                                    [tbs_check;htmlconv=no;if [var.FormMode]=Edit;then
                                    '
                                     <input type="text" name="lpj_code" value="[headblv.lpj_code;noerr]" maxlength="255" size="31" onblur="[var.InitFunction]" onkeyup="this.value=this.value.toUpperCase()" class="input" "readonly" style="font-weight:bold;font-size:13px;">
                                     <input type="hidden" name="lpj_id" value="[headblv.lpj_id;noerr]">
                                     '
                                    ;else
                                    '
                                    AUTO GENERATE BY SYSTEM
                                    <input type="hidden" name="lpj_id" value="AUTO NUMBERED BY SYSTEM">
                                    '
                                    ]
                                </td>
                                <!--<td class="fieldCaption"><input type="text" name="(bln.project_id)" value="[headblv.project_id;noerr]" maxlength="255" size="10" onblur='[var.InitFunction]' onkeyup="this.value=this.value.toUpperCase()" class="input" [tbs_check;if [var.FormMode]=Edit;then 'readonly';else '']></td>-->
                              </tr>
                              
                              <tr>
                                <td class="fieldCaption" align="right">Job Order Ref</td>
                                <td class="fieldCaption">:</td>
                                <td class="fieldCaption">
                                    <select name="joList" id="input" [tbs_check;if [var.FormMode]=Edit;then 'disabled';else ''] onchange="GetJo();">
                                        <option value="" selected>Select Value</option>
                                        <option value="1">Job Order</option>
                                    </select>
                                <input type="hidden" id="jo_ido" name="jo_ido" value="[headblv.jo_id;noerr]" class="input" maxlength="50"  size="10" [tbs_check;if [var.FormMode]=Edit;then 'disabled';else '']>
                                <input type="text" id="jo_code" name="jo_code" value="[headblv.jo_code;noerr]" maxlength="255" size="25" class="input" readonly>
                                </td>
                                <!--<td class="fieldCaption"><input type="text" name="(bln.project_id)" value="[headblv.project_id;noerr]" maxlength="255" size="10" onblur='[var.InitFunction]' onkeyup="this.value=this.value.toUpperCase()" class="input" [tbs_check;if [var.FormMode]=Edit;then 'readonly';else '']></td>-->
                              </tr>
                              </tr>
														  <tr>
															<td class="fieldCaption" align="right">Document Reference</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																<input type="text" id="doc_ref" name="doc_ref" value="[headblv.doc_ref;noerr]" maxlength="255" size="25" class="input" readonly>
															</td>

														  </tr>
														  <tr>
															<td class="fieldCaption" align="right">Project Name</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																<input type="text" id="project_name" name="project_name" value="[headblv.project_name;noerr]" maxlength="255" size="25" class="input" readonly>
																<input type="hidden" name="project_id" value="[headblv.project_id;noerr]" class="input" maxlength="50" size="10">
															</td>
														  </tr>
														  <tr>
															<td class="fieldCaption" align="right">Customer</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																<input type="hidden" name="debtur" value="[headblv.debtur;noerr]" class="input" maxlength="50" size="10">
                                <input type="text" name="debnam" value="[headblv.CUNAME;noerr]" maxlength="255" size="25" class="input" readonly>
															</td>
														  </tr>
														  
														  <tr>
															<td class="fieldCaption" align="right">Staff</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																<input type="hidden" name="staff_id" value="[headblv.staff_id]" maxlength="255" size="25" class="input">
                                    <input type="text" name="staff_name" value="[headblv.nama;noerr]" maxlength="255" size="25" class="input" readonly>
															</td>
														  </tr>
														  
														  <tr>
															<td class="fieldCaption" align="right">Operation Staff</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																<input type="hidden" name="operation_staff_id" value="[headblv.operation_staff_id]" maxlength="255" size="25" class="input">
                                <input type="text" name="operation_staff_name" value="[headblv.operation_staff_name;noerr]" maxlength="255" size="25" class="input" readonly>
															</td>
														  </tr>
														  
														  <tr>
															<td class="fieldCaption" align="right">Job Order Date</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																<input type="text" id="jo_date" name="jo_date" value="[headblv.jo_date;noerr]" maxlength="255" size="25" class="input" readonly>
															</td>
														  </tr>

														  <tr>
															<td class="fieldCaption" align="right">BL no.</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																<input type="text" name="bl_no" value="[headblv.bl_no;noerr]" id="bl_val" maxlength="255" size="31" class="input" onKeyUp="this.value=this.value.toUpperCase();changeVesselText();" readonly>
															</td>
														  </tr>

														  <tr>
															<td class="fieldCaption" align="right">Invoice no.</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																<input type="text" name="invoice_no" value="[headblv.invoice_no;noerr]" maxlength="255" size="31" class="input"  onKeyUp="this.value=this.value.toUpperCase()" readonly>
																 <!--input type="text" name="invoice_no" value="[headblv.invoice_no;noerr]" maxlength="255" size="31" class="input" disabled-->
															</td>
														  </tr>

														  <tr>
															<td class="fieldCaption" align="right">Vessel</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																<input type="text" name="vessel" value="[headblv.vessel;noerr]" id="vessel_val" maxlength="255" size="31" class="input" onKeyUp="this.value=this.value.toUpperCase();" readonly>
																<!--input type="text" name="vessel" value="[headblv.vessel;noerr]" maxlength="255" size="31" class="input" disabled-->
															</td>
														  </tr>

														  <tr>
															<td class="fieldCaption" align="right">Approval Status Job Order</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																<input type="text" name="jo_appv_status" value="[headblv.jo_appv_status;noerr]" id="vessel_val" maxlength="255" size="31" class="input" onKeyUp="this.value=this.value.toUpperCase();" readonly>
															</td>
														  </tr>
                         </table>
                         <!-- END FORM SECTION -->
                         
                         
                         <!--CARGO-->
                         
                         <h3>ITEM ACTIVITY</h3>



						 <div style="overflow:auto;height:200px;">
						 <table border="0" width="700px" cellpadding="3" cellspacing="1" class="FacetFormTABLEOperational" align="left">

							<tr>
									<td nowrap class="FacetColumnTDOperational" align="center" width="35">X</td>
									<td nowrap class="FacetColumnTDOperational" align="center" width="35">No.</td>
									<td nowrap class="FacetColumnTDOperational" align="center" width="250">Item Activity</td>
									<!--td nowrap class="FacetColumnTDOperational" align="center" width="70">Qty</td>
									<td nowrap class="FacetColumnTDOperational" align="center" width="150">Packages</td>
									<td nowrap class="FacetColumnTDOperational" align="center" width="100">Weight (kg)</td>
									<td nowrap class="FacetColumnTDOperational" align="center" width="100">Volume (cbm)</td-->
									<td nowrap class="FacetColumnTDOperational" align="center" width="100">Amount</td>
									<td nowrap class="FacetColumnTDOperational" align="center">Remarks</td>
							</tr>

							<tr id="rowItem[blgItem.#]" style="display:[blgItem._display;noerr]">


								<td nowrap class="FacetDataTDOperational" align="center">
								  <input type="checkbox" name="txtCheckItem[blgItem.#]" value="[blgItem.item_id;noerr]" class="inputRadio">
								  <input type=hidden name="dk[blgItem.#]" value="D">
								</td>

								<td nowrap class="FacetDataTDOperational" align="right" align="right">
								  [blgItem.#;block=tr].
								  <input type="hidden" name="item_id[blgItem.#]" value="[tbs_check;if [var.item_id;noerr]!='';then [var.item_id;noerr] ;else '']">
								</td>


								<td nowrap class="FacetColumnTDOperational" align="center">
									 <!--select class="gridBox2" name="activitiesList[blgItem.#]" id="input" [tbs_check;if [var.FormMode]=Edit;then 'disabled';else ''] onchange="GetActivities(this.value,'[blgItem.#]');"-->
									 <select  class="gridBox2" name="activitiesList[blgItem.#]" id="input"  onchange="GetActivities(this.value,'[blgItem.#]');">
									   <option value="" selected>Activities</option>
									   <option value="1">Select</option>
									 </select>
									 <input type="hidden" name="activities_id[blgItem.#]" value="[blgItem.activities_id;noerr]" class="input id_activity">
									 <input type="hidden" name="activities_code[blgItem.#]" value="[blgItem.activities_code;noerr]" class="input">
								 <input type="text" name="activities_name[blgItem.#]" value="[blgItem.actname;noerr]" maxlength="255" size="15" class="input" readonly>
								</td>

								<td nowrap class="FacetColumnTDOperational" align="center">
								  <input type="text" name="item_jumlah[blgItem.#]" value="[blgItem.item_jumlah;noerr;frm='0,000.00']" onkeyup="getAmount('[blgItem.#]'); maskMode(this.name, this.value);" id="input" size="10" class="amount_item">
								</td>
								
								<!--td nowrap class="FacetColumnTDOperational" align="center">
								  <input type="text"  name="cargo_pkgs[blgCargo.#]" value="[blgCargo.cargo_pkgs;noerr]" id="input" size="10" >
								</td>

								<td nowrap class="FacetColumnTDOperational" align="center">
								  <input type="text"  name="cargo_berat[blgCargo.#]" value="[blgCargo.cargo_berat;noerr]" id="input" size="7" >
								</td>

								<td nowrap class="FacetColumnTDOperational" align="center">
								  <input type="text"  name="cargo_volume[blgCargo.#]" value="[blgCargo.cargo_volume;noerr]" id="input" size="7" >
								</td-->

								<td nowrap class="FacetColumnTDOperational" align="center">
								  <input type="text"  name="item_remarks[blgItem.#]" value="[blgItem.item_remarks;noerr]" id="input" size="30" >
								</td>


							</tr>

						 </table>
						 </div>


						 <br>

						 <!--Next Line Cargo-->
						 <table border="0" width="600" cellpadding="3" cellspacing="1" class="FacetFormTABLEOperational" align="left" style="margin-bottom:20px;">

							<tr id="" style="">

								<td nowrap class="FacetDataTDOperational" align="right">
								  <input name="FormAction" type="button" value="Delete Line Item" class="button" onClick="DeleteLinesItem()">
								  <input name="FormAction" type="button" value="Next Line Item" class="button" onClick="return (AddFormGridItem(this,'[var.HTMLFormName].cargo_type'))">
								</td>

							</tr>

						 </table>
						 <!--End Next Line Cargo-->
                         
                         <!--END CARGO-->

                         </td>

                         <td valign="top">

                             <!--DATA CARGO-->


                             <!--Canvas-->
                             <table>

                             
                             <!--Canvas 1-->

                             <tr>
                                <td>

                             <h3>BS</h3>

                             <!--Revenue-->
                             <table border="0" width="625" cellpadding="3" cellspacing="1" class="FacetFormTABLEOperational" align="left" style="margin-bottom:20px;">

                                <tr>
                                    <td nowrap class="FacetColumnTDOperational" align="center" width="100">Currency</td>
                                    <td nowrap class="FacetColumnTDOperational" align="center" width="175">BS Amount</td>
                                    <td nowrap class="FacetColumnTDOperational" align="center" width="175">Actual Amount</td>
                                    <td nowrap class="FacetColumnTDOperational" align="center" width="175">Margin</td>
                                </tr>
                                <tr>
                                    <td nowrap class="FacetColumnTDOperational" align="center">IDR </td>
                                    <td nowrap class="FacetDataTDOperational" align="center"><input type="text" name="bspl_idr" value="[headblv.bspl_idr;noerr;frm='0,000.00']" size="23" class="input" readonly></td>
                                    <td nowrap class="FacetDataTDOperational" align="center"><input type="text" name="bsac_idr" value="[headblv.bsac_idr;noerr;frm='0,000.00']" size="23" class="input" readonly></td>
                                    <td nowrap class="FacetDataTDOperational" align="center"><input type="text" name="bsmg_idr" value="[headblv.bsmg_idr;noerr;frm='0,000.00']" size="23" class="input" readonly></td>
                                </tr>
                                <!--tr>
                                    <td nowrap class="FacetColumnTDOperational" align="center">USD </td>
                                    <td nowrap class="FacetDataTDOperational" align="center"><input type="text" name="bsac_usd" value="[headblv.rbt_usd;noerr;frm='0,000.00']" size="23" class="input" readonly></td>
                                    <td nowrap class="FacetDataTDOperational" align="center"><input type="text" name="bspl_usd" value="[headblv.rat_usd;noerr;frm='0,000.00']" size="23" class="input" readonly></td>
                                    <td nowrap class="FacetDataTDOperational" align="center"><input type="text" name="bsmg_idr" value="[headblv.rat_idr;noerr;frm='0,000.00']" size="23" class="input" readonly></td>
                                </tr-->

                             </table>



                             <!--End Revenue-->


                             <!--End Canvas 1-->
                             </td>

                           </tr>

                           </table>

                           <!--End Canvas-->


                         </td>

                         </tr>
                         </table>

                         <!--END TABLE MASTER-->

                                </td>
                            </tr>
                        </table>


                        <!--GRID-->

                        <hr size="1" color="DFDFDF">
                        <div id="spanHeader" style="height: 25px; vertical-align: top; overflow-y: noscroll;">
                        <table border="0" width="530" cellpadding="3" cellspacing="1" class="FacetFormTABLEOperational" align="left">

                                <tr>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="35">X</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="35">No.</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="240">BS</td>
                                        <!--td nowrap class="FacetColumnTDOperational" align="center" width="150">Disburgement</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="50">Qty</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="165">Unit</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="65">Currency</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="110">Rate</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="110">Amount</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="110">Base Amount</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="150">Tax Rate</td-->
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="110">BS Date</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="110">Amount</td>
                                        <!--td nowrap class="FacetColumnTDOperational" align="center" width="120">Payment To</td-->
                                        <!--td nowrap class="FacetColumnTDOperational" align="center">Bill To (Header Debitur as default)</td-->
                                        
                                </tr>
                        </table>
                        </div>




                        <div id="spanDetail" class="tariffgrid" style="height: 200px; vertical-align: top; overflow: auto;">

                            <!--Edited by van Smith-->

                            <table border="0" width="530" cellpadding="3" cellspacing="1" class="FacetFormTABLEOperational" align="left">

                                <tr id="[blg.#]" style="display:[blg._display;noerr]">

                                        <td nowrap class="FacetDataTDOperational" align="center" width="35">
                                          <input type="checkbox" name="txtCheck[blg.#]" value="[blg.act_id;noerr]" class="inputRadio">
                                          <input type=hidden name="dk[blg.#]" value="D">
                                        </td>

                                        <td nowrap class="FacetDataTDOperational" align="right" width="35" align="right">
                                          [blg.#;block=tr].
                                          <input type="hidden" name="lpj_id[blg.#]" value="[tbs_check;if [var.jo_id;noerr]!='';then [var.jo_id;noerr] ;else '']">
                                        </td>

                                        <td nowrap class="FacetColumnTDOperational" align="center" width="240">

                                           <select class="gridBox"  name="advList[blg.#]" id="input" onchange="GetBS(this.value,'[blg.#]');">
                                             <option value="" selected>BS</option>
                                             <option value="1">Select</option>
                                           </select>
                                           <input type="hidden" name="adv_id[blg.#]" value="[blg.adv_id;noerr]" class="input">
                                           <input type="text" name="adv_code[blg.#]" value="[blg.adv_code;noerr]" class="input">
                                           <!--input type="text" name="services_name[blg.#]" value="[blg.services_name;noerr]" maxlength="255" size="15" class="input" readonly-->
                                        </td>
                                        
                                        <!--td nowrap class="FacetColumnTDOperational" align="center" width="150">
                                          <select name="disburgement[blg.#]" class="input" id="disburgement">
												  <option value="">-</option>
												  <option value="Disburgement">Disburgement</option>
												  <option value="Non-Disburgement">Non Disburgement</option>
												  <option>[blg.disburgement;selected;noerr]</option>
										   </select>
                                        </td>

                                        <td nowrap class="FacetColumnTDOperational" align="center" width="50"><input type="text"  name="qty[blg.#]" value="[blg.qty;noerr]" id="input" class="gridBox" onkeyup="getBaseAmount('[blg.#]'); maskMode(this.name,this.value);" size="4" ></td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="165">
                                           <select name="unit[blg.#]" class="input">
                                             <option value="">-</option>
                                             <option value="[unit.unit_code]">[unit.unit_name;block=option]</option>
                                             <option>[blg.unit;selected;noerr]</option>
                                           </select>
                                        </td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="65">

                                           <select name="curr[blg.#]" id="input" onchange="getBaseAmount('[blg.#]')">
                                              <option value="">-</option>
                                              <option value="IDR">IDR</option>
                                              <option value="USD">USD</option>
                                              <option>[blg.curr;selected;noerr]</option>
                                           </select>
                                        </td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="110"><input type="text"  name="rate[blg.#]" value="[blg.rate;noerr;frm='0,000.00']" id="input" onkeyup="getBaseAmount('[blg.#]'); maskMode(this.name,this.value);" size="10" ></td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="110"><input type="text"  name="amount[blg.#]" value="[blg.amount;noerr;frm='0,000.00']" id="input" size="10" readonly class="amount"></td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="110"><input type="text"  name="base_amount[blg.#]" value="[blg.base_amount;noerr;frm='0,000.00']" id="input" size="10" readonly></td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="150">

                                           <select name="tax_rate[blg.#]" class="input" onchange="getBaseAmount('[blg.#]')">
                                             <option value="">-</option>
                                             <option value="[taxRate.calculate]-[taxRate.tax_kind]">[taxRate.description;block=option]</option>
                                             <option>[blg.tax_rate;selected;noerr]</option>
                                           </select>

                                        </td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="110">
                                           <input type="text" name="adv_date[blg.#]" value="[blg.tax_amount;noerr;frm='0,000.00']" id="input" size="10" readonly>
                                           <input type="hidden" name="tax_amount_usd[blg.#]" value="[blg.tax_amount_usd;noerr;]" id="input" size="10" readonly>
                                        </td-->
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="110">
                                        	<input type="text"  name="adv_date[blg.#]" value="[blg.adv_date;noerr;]" id="input" size="10" readonly >
                                        </td>
                                        
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="110">
                                        	<input type="hidden"  name="jumlah[blg.#]" value="[blg.jumlah;noerr;frm='0,000.00']" id="input" size="10" onblur="getAmount('[blg.#]');" readonly >
                                        	<input type="text"  name="rupiah[blg.#]" value="[blg.rupiah;noerr;frm='0,000.00']"  id="input" size="10" onblur="getAmount('[blg.#]');" class="amount" readonly>
                                        </td>
																				
                                        <!--td nowrap class="FacetColumnTDOperational" align="center" width="120">                                        
                                           <input type="text" name="total_amount[blg.#]" value="[blg.total_amount;noerr;frm='0,000.00']" id="input" size="12" readonly>
                                           <input type="hidden" name="total_amount_usd[blg.#]" value="[blg.total_amount_usd;noerr;]" id="input" size="16" readonly>
                                           <input type="hidden"  name="payment_status_id[blg.#]" value="" id="input">
                                           <input type="hidden"  name="dev_after_tax[blg.#]" value="[blg.dev_after_tax;noerr]" id="input">
                                           <input type="hidden"  name="mul_after_tax[blg.#]" value="[blg.mul_after_tax;noerr]" id="input">
                                           <input type="hidden"  name="nibt[blg.#]" value="[blg.nibt;noerr]" id="input">
                                           <input type="hidden"  name="niat[blg.#]" value="[blg.niat;noerr]" id="input"> 
                                           <!--
                                            <select name="payment_status_id[blg.#]" class="input">
                                             <option value="">-</option>
                                             <option value="[paymentStatus.payment_status_id]">[paymentStatus.payment_status_name;block=option]</option>
                                             <option>[blg.payment_status_id;selected;noerr]</option>
                                           </select>
                                           -->
                                        <!--/td-->
                                        
                                        <!--td nowrap class="FacetColumnTDOperational" align="center">
                                        
											<select name="debturList" id="input" onchange="GetReceived_2(this.value,'[blg.#]');">
											<option value="" selected>Select Value</option>
											<option value="1">Customer</option>
											</select>
											<input type="hidden" name="debtur_fin[blg.#]" value="[blg.bill_to;noerr]" class="input" maxlength="50" size="10">
											<input type="hidden" name="debtur[blg.#]" value="[blg.bill_to;noerr]" class="input" maxlength="50" size="10">
											<input type="text" name="debnam[blg.#]" value="[blg.CUNAME;noerr]" maxlength="255" size="10" class="input" readonly>
                                        
                                        </td-->
                                        

                                    </tr>
                            </table>

                            <!--End Edited by van Smith-->

                        </div>

                        <!--END GRID-->


                        <!--BUTTON-->
                        <div id="spanButton" style="height: 35px; vertical-align: top; overflow-y: noscroll;">
                        <table border="0" width="570" cellpadding="3" cellspacing="1" class="FacetFormTABLEOperational" align="left">
                                <tr>
                                    <td align="right" class="FacetColumnTDOperational">

                                           <table border="0" cellspacing="2" cellpadding="0">
                                                   <tr>
                                                           <td>
                                                             <input name="FormAction" type="button" value="Next Line" class="button" onClick="return (AddFormGridProject(this,'[var.HTMLFormName].qty'))">
                                                           </td>
                                                           <td>
                                                                <input name="FormAction" type="button" value="Delete Line" class="button" onClick="DeleteLines()">
                                                           </td>
                                                           <td>
                                                             <input name="FormAction" type="submit" value="Save" class="button" ONCLICK="return checkVerification();">
                                                           </td>
                                                           <!--
                                                           <td>[tbs_check;block=td;if [var.USER_CANDELETE]=1]
                                                            <input type="button" name="Action" value="Delete" class="button" onClick="if (confirm('Are you sure want to delete ?')) {document.[var.HTMLFormName].action='[sys.script_name]?FormAction=Delete&[var.PRIMARY_KEY]=[var.PRIMARY_VALUE]&PageMode=Form&form=[var.HTMLFormName]';[var.HTMLFormName].submit();}">
                                                           </td>
                                                           -->
                                                           <td>
                                                             <input name="FormAction" type="submit" value="Cancel" class="button" onClick="self.location.replace('[sys.script_name]')">
                                                           </td>
                                                   </tr>
                                           </table>


                                    </td>
                                        </td>
                                </tr>

                        </table>
                        </div>

                        <!--END BUTTON-->


                    </td>
                </tr>

                </form>

            </table>
            </td>
        </tr>
        <tr>
            <td>
            <br>
            <table border="0" cellspacing="0" cellpadding="0" width="100%">
                <tr>
                    <td class="footer1"><img src="images/spacer.gif" height="1" width="1"></td>
                </tr>
                <!--tr>
                    <td class="footer2">Prototype Test - Web Application</td>
                </tr-->
            </table>
            </td>
        </tr>
    </table>
 </body>


 <iframe width="174" height="189" name="gToday:normal:agenda.js" id="gToday:normal:agenda.js" src="[var.ROOT_DIR]js/Calendar/pop/ipopeng.htm" scrolling="no" frameborder="0" style="LEFT: -500px; POSITION: absolute; TOP: 0px; VISIBILITY: visible; Z-INDEX: 999"></iframe>

 <script>

 $(function() {
     //alert("okokok");
     GetRevenue();
     LoadThisForm();
 });

 [var.InitFunction]


 SetDK(1,'K');
 document.[var.HTMLFormName].total_trans.value = SumTotal("jumlah");
 
function GetJo() {
            //newwin = window.open("ais_transaction_jolist.php?FormName=[var.HTMLFormName]&need_another_var="+need_another_var,"toolcalc","height=400,width=640,noscroll,resizable");
            newwin = window.open("ais_transaction_jolist.php?FormName=[var.HTMLFormName]&PageMode=LPJ&SendToBack=1", "toolcalc","height=400,width=640,noscroll,resizable");
}
 
function SetDK(idx,val) {
   //eval("dk = document.[var.HTMLFormName].dk"+idx+".value;");
   //if (dk=='') eval("document.[var.HTMLFormName].dk"+idx+".value='"+val+"';");
   return true;
}

function LoadThisForm(){
	changeVesselText();
}

function IsNumeric(sText){
   var ValidChars = "0123456789.,";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   return IsNumber;

}

function checkVerification(){
    var checksum = 0;
    var errorMsg = "";

    var doc_ref = eval("document.[var.HTMLFormName].doc_ref.value");
    var project_id = eval("document.[var.HTMLFormName].project_id.value");
    var debtur = eval("document.[var.HTMLFormName].debtur.value");
    var staff_id = eval("document.[var.HTMLFormName].staff_id.value");
	var operation_staff_id = eval("document.[var.HTMLFormName].operation_staff_id.value");   
    var invoice_no = eval("document.[var.HTMLFormName].invoice_no.value");
    var vessel = eval("document.[var.HTMLFormName].vessel.value");
    var disburgement = eval("document.[var.HTMLFormName].disburgement.value");
    var jo_appv_status = eval("document.[var.HTMLFormName].jo_appv_status.value");

    if(doc_ref == "")
    {
        errorMsg+= "Document Reference should not empty\n";
    }

    if(project_id == "")
    {
        errorMsg+= "Project should not empty\n";
    }

    if(debtur == "")
    {
        errorMsg+= "Customer should not empty\n";
    }

    if(staff_id == "")
    {
        errorMsg+= "Staff should not empty\n";
    }
	
	if(operation_staff_id == "")
    {
        errorMsg+= "Operation Staff should not empty\n";
    }
    
    
    if(disburgement == "")
    {
        errorMsg+= "Disburgement status should not empty\n";
    }
   
    if(invoice_no == "")
    {
        errorMsg+= "Invoice Number should not empty\n";
    }

    if(vessel == "")
    {
        errorMsg+= "Vessel should not empty\n";
    }

    if(jo_appv_status == "")
    {
        errorMsg+= "Approval should not empty\n";
    }

   
    if(errorMsg != "")
    {
        alert(errorMsg);
        return false;
    }

    else
    {
        return true;
    }
    

}

function DeleteLines(){
    $("input[name^=txtCheck]").each(
      function(){
        if($(this).attr('checked')) {
            //alert($(this).val());
            var num = String($(this).attr('name')).replace('txtCheck','');
            //alert('num: ' + num);
            $('tr#'+num).remove();
        }
      }
    );
}

function DeleteLinesItem(){
    $("input[name^=txtCheckItem]").each(
      function(){
        if($(this).attr('checked')) {
            //alert($(this).val());
            var num = String($(this).attr('name')).replace('txtCheckItem','');
            //alert('num: ' + num);
            $('tr#rowItem'+num).remove();
        }
      }
    );
}

function SubmitPDF() {
      str_url = '[sys.script_name]?PageMode=PDF&jo_id=[var.jo_id]';
      OpenPDF(str_url);
      return false;
}

function changeVesselText(){
	var bl_val = $("#bl_val").val();
	
	if(bl_val != "")
	{
	   $("#vessel_text").html("Vessel");	
	}
	
	else
	{
	   $("#vessel_text").html("Ex Vessel");	
	}
	
}

function getIncludeTax(tax_val,amount){
   var tax_res = 0.1/(1.1 - tax_val) * amount;   
   return tax_res;
}

function getBaseAmount(urut){

   oMask = new Mask('#,###.#0', 'number');

   var qty = eval("document.[var.HTMLFormName].qty"+urut+".value");
   var rate = eval("document.[var.HTMLFormName].rate"+urut+".value");
   var curr = eval("document.[var.HTMLFormName].curr"+urut+".value");
   var tax_rate = eval("document.[var.HTMLFormName].tax_rate"+urut+".value");

   var rbt_idr = 0;
   var rbt_usd = 0;
   var rat_idr = 0;
   var rat_usd = 0;

   var amountCounter = 0;
   var totalAmountCounter = 0;
   var currCounter = "";
   var counter = "";
   var n = 0;
   var reccount = 0;
   var amount = 0;
   var baseAmount = 0;
   var tax_amount = 0;
   var tax_amount_usd = 0;
   var total_amount = 0;
   var total_amount_usd = 0;

   var dev_after_tax = 0;
   var mul_after_tax = 0;
   var nibt = 0;
   var niat = 0;

   //Parse the Tax
   var tax_arr = tax_rate.split("-");

   var tax_val = parseFloat(tax_arr[0]);
   var tax_text = tax_arr[1];
   //End Parse the Tax


   //error handling for rate
   if(rate == "") rate = 0;
   else if (!IsNumeric(rate)) alert('Rate should be Numeric value');

   //error handling for Quantity
   if(qty == "") qty = 0;
   else if (!IsNumeric(qty)) alert('Quantity should be Numeric value');

   //error handling for Tax Rate
   if(tax_rate == "") tax_rate = 0;

   //Parse to Integer
   //qty = parseInt(qty);
   //rate = parseInt(rate);

   if(curr == "IDR")
   {
      rate = String(rate);
      rate = (rate.replace(/,/g, "")) * 1;

      baseAmount = qty * rate;
      amount = qty * rate;
   }

   else if(curr == "USD")
   {
      rate = String(rate);
      rate = (rate.replace(/,/g, "")) * 1;

      baseAmount = qty * rate * [var.kursUSD];
      amount = qty * rate;
   }


   //Counting the Total and Tax

   if(tax_text == "exclude")
   {
	 
	 if(curr == "IDR")
     {  
	   
		 baseAmount = String(baseAmount);
		 baseAmount = (baseAmount.replace(/,/g, "")) * 1;
		 tax_amount = baseAmount * tax_val;
		 tax_amount_usd = 0;

		 tax_amount = String(tax_amount);
		 tax_amount = (tax_amount.replace(/,/g, "")) * 1;
		 total_amount = baseAmount + tax_amount;
		 total_amount_usd = 0;
     
     }
     
     else if(curr == "USD")
     {
		 baseAmount = String(baseAmount);
		 baseAmount = (baseAmount.replace(/,/g, "")) * 1;		
		 tax_amount = amount * tax_val * [var.kursUSDTax];
		 tax_amount_usd = amount * tax_val.toFixed(2);
		 

		 tax_amount = String(tax_amount);
		 tax_amount = (tax_amount.replace(/,/g, "")) * 1;
		 total_amount = baseAmount + tax_amount;
		 total_amount_usd = amount + tax_amount_usd;
		 total_amount_usd.toFixed(2);
	 }
 
   }

   else if(tax_text == "include")
   {
     
     if(curr == "IDR")
     {
     
		 amount = String(amount);
		 amount = (amount.replace(/,/g, "")) * 1;

		 tax_amount = getIncludeTax(tax_val,amount);		 
		 tax_amount = tax_amount.toFixed(2);
		 tax_amount_usd = 0;
		 
		 total_amount = baseAmount;
		 total_amount_usd = 0;
     
     }
     
     else if(curr == "USD")
     {
		 
		 amount = String(amount);
		 amount = (amount.replace(/,/g, "")) * 1;

		 tax_amount = getIncludeTax(tax_val,amount) * [var.kursUSDTax];		 		 
		 tax_amount = tax_amount.toFixed(2);
		 tax_amount_usd = getIncludeTax(tax_val,amount);
		 tax_amount_usd = tax_amount_usd.toFixed(2);
		 
		 total_amount = baseAmount;
		 total_amount_usd = amount.toFixed(2);
		 
	 }
     
   }
   
   else
   {
	   
	 if(curr == "IDR")
     {  
	   
		 baseAmount = String(baseAmount);
		 baseAmount = (baseAmount.replace(/,/g, "")) * 1;
		 total_amount = baseAmount;
		 total_amount_usd = 0;
     
     }
     
     else if(curr == "USD")
     {
		 baseAmount = String(baseAmount);
		 baseAmount = (baseAmount.replace(/,/g, "")) * 1;
		 total_amount = baseAmount;
		 total_amount_usd = amount;
	 }
	   
   }
   
   
   //Not Visible on front end

   if(curr == "IDR")
   {
      dev_after_tax = amount - tax_amount;
      mul_after_tax = rate * tax_val;
      nibt = dev_after_tax + mul_after_tax;
      niat = dev_after_tax + mul_after_tax + tax_amount;
   }

   else if(curr == "USD")
   {
      dev_after_tax = baseAmount - tax_amount;
      mul_after_tax = rate * tax_val * [var.kursUSD];
      nibt = dev_after_tax + mul_after_tax;
      niat = dev_after_tax + mul_after_tax + tax_amount;
   }



    //Change to Mask Format --Start--
    var maskBaseAmount = oMask.format(baseAmount);
    var maskAmount = oMask.format(amount);
    var maskTaxAmount = oMask.format(tax_amount);
    var maskTotalAmount = oMask.format(total_amount);    
    //Change to Mask Format --End--
    
    

   /*
   eval("document.[var.HTMLFormName].base_amount"+urut+".value = "+baseAmount);
   eval("document.[var.HTMLFormName].amount"+urut+".value = "+amount);
   eval("document.[var.HTMLFormName].tax_amount"+urut+".value = "+tax_amount);
   eval("document.[var.HTMLFormName].total_amount"+urut+".value = "+total_amount);
   */

   $("input[name=base_amount"+urut+"]").val(maskBaseAmount);
   $("input[name=amount"+urut+"]").val(maskAmount);
   $("input[name=tax_amount"+urut+"]").val(maskTaxAmount);
   $("input[name=total_amount"+urut+"]").val(maskTotalAmount);
   
   
   //Additional Field for USD Amount and tax
   $("input[name=tax_amount_usd"+urut+"]").val(tax_amount_usd);
   $("input[name=total_amount_usd"+urut+"]").val(total_amount_usd);
   //End Additional Field for USD Amount and tax
   

   //Hidden value Start (for financial accounting)
   eval("document.[var.HTMLFormName].dev_after_tax"+urut+".value = "+dev_after_tax);
   eval("document.[var.HTMLFormName].mul_after_tax"+urut+".value = "+mul_after_tax);
   eval("document.[var.HTMLFormName].nibt"+urut+".value = "+nibt);
   //eval("document.[var.HTMLFormName].niat"+urut+".value = "+niat);
   //Hidden value End (for financial accounting)
   
   $(".amount:visible").each(function(n) {
       n = n+1;
       reccount = n;
       counter = this.name;
       counter = counter.substring(6);
       
       //Count The RBT and RAT

       eval("amountCounter = document.[var.HTMLFormName].amount"+counter+".value");
       eval("taxCounter = document.[var.HTMLFormName].tax_amount"+counter+".value");
       eval("totalAmountCounter = document.[var.HTMLFormName].total_amount"+counter+".value");
       eval("taxUSDCounter = document.[var.HTMLFormName].tax_amount_usd"+counter+".value");
       eval("totalAmountUSDCounter = document.[var.HTMLFormName].total_amount_usd"+counter+".value");
       eval("currCounter = document.[var.HTMLFormName].curr"+counter+".value");
       
       amountCounter = String(amountCounter);
       amountCounter = (amountCounter.replace(/,/g, "")) * 1;
       
       taxCounter = String(taxCounter);
       taxCounter = (taxCounter.replace(/,/g, "")) * 1;
       
       totalAmountCounter = String(totalAmountCounter);
       totalAmountCounter = (totalAmountCounter.replace(/,/g, "")) * 1;
       
       
       if(currCounter == "IDR")
       {
          //amountCounter = parseInt(amountCounter);
       
          if((amountCounter != "") || (amountCounter != "NaN"))
          {
            rbt_idr+= totalAmountCounter - taxCounter;
          }
          else
          {
            rbt_idr+= 0;
          }
       }

       else if(currCounter == "USD")
       {
          //amountCounter = parseInt(amountCounter);
       
          if((amountCounter != "") || (amountCounter != "NaN"))
          {
            rbt_usd+= totalAmountUSDCounter - taxUSDCounter;
          }
          else
          {
            rbt_usd+= 0;
          }
       }

       if(totalAmountCounter != "")
       {
         //totalAmountCounter = parseInt(totalAmountCounter);        

         rat_idr+= totalAmountCounter;
       }
       else
       {
         rat_idr+= 0;
       }

   });




   /*eval("document.[var.HTMLFormName].rbt_idr.value = "+rbt_idr);
   eval("document.[var.HTMLFormName].rbt_usd.value = "+rbt_usd);
   eval("document.[var.HTMLFormName].rat_idr.value = "+rat_idr);*/
   eval("document.[var.HTMLFormName].rat_usd.value = 0");

   //Change to Mask Format --Start--
   maskrbt_idr = oMask.format(rbt_idr);
   maskrbt_usd = oMask.format(rbt_usd);
   maskrat_idr = oMask.format(rat_idr);
   //Change to Mask Format --end--

   $("input[name=rbt_idr]").val(maskrbt_idr);
   $("input[name=rbt_usd]").val(maskrbt_usd);
   $("input[name=rat_idr]").val(maskrat_idr);

   //END Count The RBT and RAT


}

function GetRevenue() {

    oMask = new Mask('#,###.#0', 'number');

    var amount = 0;
    var baseAmount = 0;
    var tax_amount = 0;
    var tax_amount_usd = 0;    
    var total_amount = 0;
    var total_amount_usd = 0;
    var rbt_idr = 0;
    var rbt_usd = 0;
    var rat_idr = 0;
    var rat_usd = 0;
    var amountCounter = 0;
    var totalAmountCounter = 0;
    var currCounter = "";
    
    

        //Count The CBT and CAT
    $(".amount:visible").each(function(n) {
       n = n+1;
       reccount = n;
       counter = this.name;
       counter = counter.substring(6);

       //Count The RBT and RAT

       eval("amountCounter = document.[var.HTMLFormName].amount"+counter+".value");
       eval("taxCounter = document.[var.HTMLFormName].tax_amount"+counter+".value");
       eval("totalAmountCounter = document.[var.HTMLFormName].total_amount"+counter+".value");
       eval("taxUSDCounter = document.[var.HTMLFormName].tax_amount_usd"+counter+".value");
       eval("totalAmountUSDCounter = document.[var.HTMLFormName].total_amount_usd"+counter+".value");
       eval("currCounter = document.[var.HTMLFormName].curr"+counter+".value");
       
       amountCounter = String(amountCounter);
       amountCounter = (amountCounter.replace(/,/g, "")) * 1;
       
       taxCounter = String(taxCounter);
       taxCounter = (taxCounter.replace(/,/g, "")) * 1;
       
       totalAmountCounter = String(totalAmountCounter);
       totalAmountCounter = (totalAmountCounter.replace(/,/g, "")) * 1;
       
       
       if(currCounter == "IDR")
       {
          //amountCounter = parseInt(amountCounter);
       
          if((amountCounter != "") || (amountCounter != "NaN"))
          {
            rbt_idr+= totalAmountCounter - taxCounter;
          }
          else
          {
            rbt_idr+= 0;
          }
       }

       else if(currCounter == "USD")
       {
          //amountCounter = parseInt(amountCounter);
       
          if((amountCounter != "") || (amountCounter != "NaN"))
          {
            rbt_usd+= totalAmountUSDCounter - taxUSDCounter;
          }
          else
          {
            rbt_usd+= 0;
          }
       }

       if(totalAmountCounter != "")
       {
         //totalAmountCounter = parseInt(totalAmountCounter);        

         rat_idr+= totalAmountCounter;
       }
       else
       {
         rat_idr+= 0;
       }

   });




   /*eval("document.[var.HTMLFormName].rbt_idr.value = "+rbt_idr);
   eval("document.[var.HTMLFormName].rbt_usd.value = "+rbt_usd);
   eval("document.[var.HTMLFormName].rat_idr.value = "+rat_idr);*/
   eval("document.[var.HTMLFormName].rat_usd.value = 0");

   //Change to Mask Format --Start--
   maskrbt_idr = oMask.format(rbt_idr);
   maskrbt_usd = oMask.format(rbt_usd);
   maskrat_idr = oMask.format(rat_idr);
   //Change to Mask Format --end--

   $("input[name=rbt_idr]").val(maskrbt_idr);
   $("input[name=rbt_usd]").val(maskrbt_usd);
   $("input[name=rat_idr]").val(maskrat_idr);

   //END Count The CBT and CAT




}

function GetServices(val,no_urut) {
      newwin = window.open("ais_transaction_serviceslist.php?FormName=[var.HTMLFormName]&no_urut="+no_urut,"toolcalc","height=400,width=640,noscroll,resizable");
}

function GetStaff(val,need_another_var) {
            newwin = window.open("ais_transaction_stafflist.php?FormName=[var.HTMLFormName]&need_another_var="+need_another_var,"toolcalc","height=400,width=640,noscroll,resizable");
}
 
function GetStaffOpr(val,need_another_var) {
            newwin = window.open("ais_transaction_stafflist.php?FormName=[var.HTMLFormName]&need_another_var="+need_another_var,"toolcalc","height=400,width=640,noscroll,resizable");
}

function OpenPrincipal (number) {
        newwin = window.open("ais_transaction_receipt_entry.php?PageMode=Page2&FormName=[var.HTMLFormName]&Number="+number,"vessel","height=105,width=300,noscroll,noresizable");
}

function OpenRemark (number) {
        newwin = window.open("ais_transaction_dn.php?PageMode=Remark&FormName=[var.HTMLFormName]&Number="+number,"remarks","height=105,width=300,noscroll,noresizable");
}

function OpenPrint (number) {
        newwin = window.open("ais_transaction_dn.php?PageMode=PrintPreview&nobkt="+number,"print","height=650,width=600,noscroll,noresizable");
}

function GetSkada() {
         skada1 = document.[var.HTMLFormName].thbl.value;
         if (skada1.length) LoadRPC ("iLoader", "[var.FileName]", "thbl="+document.[var.HTMLFormName].thbl.value);
}

function GetTotal () {
         document.[var.HTMLFormName].total_trans.value = SumTotal("jumlah");
}


 /* added by dyah <dyah.mahrani@gmail.com>
 * 23 juli 2009
 * desc: COA filter based on group <payable/receivable>
 * */


function getCashType(){
    var frm = document.[var.HTMLFormName].cash_type;
    return frm.options[frm.selectedIndex].value;
}

var reccount = 1;
//if (reccount==0) reccount=1; else reccount=5;
var last;
/*
function AddFormGridProject (cname,firstelemen) {
    var lastname ="";
    //var debtur_head = document.[var.HTMLFormName].debtur.value;
    //var debtur_fin_head = document.[var.HTMLFormName].debtur_fin.value;
	//var debnam_head = document.[var.HTMLFormName].debnam.value;
    
    if (VerifyGridProject(reccount)==false) {
        return false
    }

    $(".gridBox:visible").each(function(n) {
        n = n+1;
        reccount = n;
        lastname = this.name;
    });
    
        
    lastname = lastname.substring(7);

    lastname = parseInt(lastname)+1;

    //reccount = 5;
    reccount = parseInt(reccount)+1;

    //alert("reccount: " + reccount);
 	
	//eval("document.[var.HTMLFormName].debtur"+reccount+".value = debtur_head");
	//eval("document.[var.HTMLFormName].debtur_fin"+reccount+".value = debtur_fin_head");
	//eval("document.[var.HTMLFormName].debnam"+reccount+".value = debnam_head");

    if (reccount>=100) {
        cname.disabled = true;
    }

    var objrow = document.getElementById(lastname);

    if (objrow.style.display == 'none') {
        objrow.style.display = '';
    }

    eval(firstelemen+''+lastname+'.focus()');

    return false;
}
*/

function AddFormGridProject (cname,firstelemen) {
    var lastname ="";
    if (VerifyGridItem(reccount)==false) {
        return false
    }

    $(".gridBox:visible").each(function(n) {
        n = n+1;
        reccount = n;
        lastname = this.name;
    });

    lastname = lastname.substring(7);

    lastname = parseInt(lastname)+1;


    //reccount = 5;
    reccount = parseInt(reccount)+1;

    //alert("reccount: " + reccount);

    if (reccount>=100) {
        cname.disabled = true;
    }

    //var objrow = document.getElementById("rowItem"+lastname);
    var objrow = document.getElementById(lastname);

    if (objrow.style.display == 'none') {
        objrow.style.display = '';
    }

    eval(firstelemen+''+lastname+'.focus()');

    return false;
}

function AddFormGridItem (cname,firstelemen) {
    var lastname ="";
    if (VerifyGridItem(reccount)==false) {
        return false
    }

    $(".gridBox2:visible").each(function(n) {
        n = n+1;
        reccount = n;
        lastname = this.name;
    });

    lastname = lastname.substring(14);

    lastname = parseInt(lastname)+1;


    //reccount = 5;
    reccount = parseInt(reccount)+1;

    //alert("reccount: " + reccount);

    if (reccount>=100) {
        cname.disabled = true;
    }

    var objrow = document.getElementById("rowItem"+lastname);

    if (objrow.style.display == 'none') {
        objrow.style.display = '';
    }

    eval(firstelemen+''+lastname+'.focus()');

    return false;
}

function VerifyGridProject (x) {
    err_message = '';
    last_focus =0;
    if (err_message.length) {//alert(err_message);
    return false} else return true
}

function VerifyGridItem (x) {
    err_message = '';
    last_focus =0;
    if (err_message.length) {//alert(err_message);
    return false} else return true
}

function CheckAllGrid(firstelemen) {
        for (n=1;n<reccount;n++) {
                if (!VerifyGrid(n)) return false;
        }
        eval('fl = document.'+firstelemen+reccount+'.value');
        if (fl.length)
                if (!VerifyGrid(reccount)) return false;
return true;

}

function GetProject(val) {
    newwin = window.open("ais_transaction_projList.php?FormName=[var.HTMLFormName]&SendToBack=1&PageMode=job_order","toolcalc","height=500,width=640,noscroll,resizable");
}

function GetReceived(val) {

     var getProjectValue = document.getElementById('projectname').value;
     var project_id = eval("document.[var.HTMLFormName].project_id.value");	  
	 var msgErr = "";
      
     
     if(project_id == "")
	 {
	    msgErr+= "Project harus dipilih terlebih dahulu\n";
	 }
	  	  
	 if(msgErr == "")
	 {			
        newwin = window.open("ais_transaction_custlist_2.php?FormName=[var.HTMLFormName]&SendToBack=1&PageMode=JO&ProjectId=" + getProjectValue ,"toolcalc","height=400,width=640,noscroll,resizable");
     }
      
     else
     {
	   alert(msgErr);  
	 }
      

     
}

function GetReceived_2(val,no_urut) {

     var getProjectValue = document.getElementById('projectname').value;
     var project_id = eval("document.[var.HTMLFormName].project_id.value");	  
	 var msgErr = "";
      
     
     if(project_id == "")
	 {
	    msgErr+= "Project harus dipilih terlebih dahulu\n";
	 }
	  	  
	 if(msgErr == "")
	 {	
        newwin = window.open("ais_transaction_custlist_2.php?FormName=[var.HTMLFormName]&SendToBack=1&PageMode=Test&ProjectId=" + getProjectValue+"&no_urut="+no_urut+"&show_data=all","toolcalc","height=400,width=640,noscroll,resizable");
     }
      
     else
     {
	   alert(msgErr);  
	 }
      

     
}

function maskMode(names,values){
    //alert(tes);
    oMask2 = new Mask('#,###.##', 'number');
    $("input[name="+names+"]").val(oMask2.format(values));

}
 
function GetActivities(val,no_urut) {
      //eval("service_id = document.getElementById('services_id" + no_urut +"').value");
      //var service_id = document.getElementById("services_id").value;


        var jo_id = document.getElementById("jo_ido").value;
        //var debtur_code = document.getElementById("debtur_code").value;
        //var curr_id = document.getElementById("curr_id").value;

        //if (CheckRefAct()){
            //newwin = window.open("ais_transaction_actnrlist.php?FormName=[var.HTMLFormName]&SendToBack=1&PageMode=EntryAdvanceForm&no_urut="+ no_urut + "&jo_id=" + jo_id + "&staff_code=" + debtur_code + "&curr_id=" + curr_id, "toolcalc","height=400,width=640,noscroll,resizable");
						newwin = window.open("ais_transaction_actnrlist.php?FormName=[var.HTMLFormName]&SendToBack=1&PageMode=LPJ&no_urut="+ no_urut + "&jo_id=" + jo_id, "toolcalc","height=400,width=640,noscroll,resizable");
        //}
}
 
function GetBS(val,no_urut) {
      //eval("service_id = document.getElementById('services_id" + no_urut +"').value");
      //var service_id = document.getElementById("services_id").value;


        var jo_id = document.getElementById("jo_ido").value;
        //var debtur_code = document.getElementById("debtur_code").value;
        //var curr_id = document.getElementById("curr_id").value;

        //if (CheckRefAct()){
            //newwin = window.open("ais_transaction_actnrlist.php?FormName=[var.HTMLFormName]&SendToBack=1&PageMode=EntryAdvanceForm&no_urut="+ no_urut + "&jo_id=" + jo_id + "&staff_code=" + debtur_code + "&curr_id=" + curr_id, "toolcalc","height=400,width=640,noscroll,resizable");
						newwin = window.open("ais_transaction_bslist.php?FormName=[var.HTMLFormName]&SendToBack=1&PageMode=LPJ&no_urut="+ no_urut + "&jo_id=" + jo_id, "toolcalc","height=400,width=640,noscroll,resizable");
        //}
}

function getAmount(urut){
//alert ("test"); 
   oMask = new Mask('#,###.#0', 'number');
   
   var buffer = "";
   var bsac = 0;
   var totalbsac = 0;
   var bspl = 0;
   var totalbspl = 0;
   var margin = 0;
   
   $(".amount_item:visible").each(function(n) {
       n = n+1;
       reccount = n;
       counter = this.name;
       counter = counter.substring(11);
       
       eval("bsac = document.[var.HTMLFormName].item_jumlah"+counter+".value");
       
       buffer = String(bsac);
       bsac = (buffer.replace(/,/g, "")) * 1;
       
       totalbsac += bsac;	 

   });
   
   $(".amount:visible").each(function(n) {
       //alert (bspl);
       n = n+1;
       reccount = n;
       counter = this.name;
       counter = counter.substring(6);
       
       //rupiah
       
       eval("bspl = document.[var.HTMLFormName].rupiah"+counter+".value");
       //eval("$(\"Input[name=rupiah"+counter+"]\""+".val()");
       //$("input[name=rupiah1]").val();
       //alert(bspl);
       
       buffer = String(bspl);
       bspl = (buffer.replace(/,/g, "")) * 1;
       
       totalbspl += bspl;	 

   });
   
	 margin = totalbspl - totalbsac;
	 
   //Change to Mask Format --Start--
   maskbspl_idr = oMask.format(totalbspl);
   maskbsac_idr = oMask.format(totalbsac);
   maskbsmg_idr = oMask.format(margin);
   //Change to Mask Format --end--

   $("input[name=bspl_idr]").val(maskbspl_idr);
   $("input[name=bsac_idr]").val(maskbsac_idr);
   $("input[name=bsmg_idr]").val(maskbsmg_idr);

   //END Count The RBT and RAT
}


 
 </script>


</html>
